using System;
using System.Collections;
using System.Collections.Generic;

public static class MiniJsonExtensions
{
	public static string toJson(this Hashtable obj)
	{
		return MiniJSON.jsonEncode(obj);
	}

	public static string toJson<T>(this List<T> obj) where T : class
	{
		return MiniJSON.jsonEncode(new ArrayList(obj));
	}

	public static string toJson<T>(this T[] obj) where T : class
	{
		return MiniJSON.jsonEncode(new ArrayList(obj));
	}

	public static string toJson(this Dictionary<string, string> obj)
	{
		return MiniJSON.jsonEncode(obj);
	}

	public static ArrayList arrayListFromJson(this string json)
	{
		return MiniJSON.jsonDecode(json) as ArrayList;
	}

	public static List<T> listFromJson<T>(this string json)
	{
		ArrayList arrayList = MiniJSON.jsonDecode(json) as ArrayList;
		List<T> list = new List<T>(arrayList.Count);
		IEnumerator enumerator = arrayList.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				T item = (T)((object)obj);
				list.Add(item);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
		return list;
	}

	public static Hashtable hashtableFromJson(this string json)
	{
		return MiniJSON.jsonDecode(json) as Hashtable;
	}
}
